﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YWTSSys.DAL;
using YWTSSys.Model;
using YWTSSys.Library;
using System.Data;

namespace YWTSSys.BLL
{
    public class ORoleController
    {
        /// <summary>
        /// 添加角色
        /// </summary>      
        public static bool Add(ORoleInfo obj, string FunIds)
        {
            return ORoleDAL.Add(obj, FunIds);
        }
        /// <summary>
        /// 添加角色权限信息
        /// </summary>
        /// <param name="RoleId"></param>
        /// <param name="FunId"></param>
        /// <returns></returns>
        public static bool AddFunction(int RoleId, string FunId)        
        {
            return ORoleDAL.AddFunction(RoleId, FunId);
        }
        /// <summary>
        /// 删除角色，将会删除此角色对应的所有权限信息
        /// </summary>
        /// <param name="RoleId"></param>
        /// <returns></returns>
        public static bool Delete(int RoleId)
        {
            return ORoleDAL.Delete(RoleId);
        }
        
        /// <summary>
        /// 获取所有的角色信息
        /// </summary>
        /// <returns></returns>
        public static DataTable GetAll()
        {
            return ORoleDAL.GetAll();
        }

         /// <summary>
        /// 根据角色ID获取角色信息
        /// </summary>
        /// <param name="RoleId"></param>
        /// <returns></returns>
        public static ORoleInfo GetById(int RoleId)	    
        {
            return CBO.FillObject<ORoleInfo>( ORoleDAL.GetById(RoleId));
        }
        /// <summary>
        /// 更新角色信息
        /// </summary>
        /// <param name="RoleId"></param>
        /// <param name="RoleName"></param>
        /// <param name="Remark"></param>
        /// <returns></returns>
        public static bool Update(ORoleInfo obj, string FunIds)
        {
            return ORoleDAL.Update(obj, FunIds);
        }
        /// <summary>
        /// 根据角角ID,获取其所有的功能权限
        /// </summary>
        /// <param name="RoleId"></param>
        /// <returns></returns>
        public static List<ORoleFunctionInfo> GetRoleFunctionByRoleId(int RoleId)
        {
            return CBO.FillCollection<ORoleFunctionInfo>(ORoleDAL.GetRoleFunctionByRoleId(RoleId));
        }

         /// <summary>
        /// 根据角色ID获取角色对应菜单信息2011-6-14
        /// </summary>
        /// <param name="RoleId"></param>
        /// <returns></returns>
        public static List<OMenuInfo> GetRoleMenu(int RoleId)
        {
            return CBO.FillCollection<OMenuInfo>(ORoleDAL.GetRoleMenu(RoleId));
        }

        /// <summary>
        /// 获取角色对应的菜单权限信息返回OMenuPermissionInfo类
        /// </summary>
        /// <param name="RoleId"></param>
        /// <returns></returns>
        public static List<OMenuPermissionInfo> GetPermissionByRoleId(int RoleId)
        {
            return CBO.FillCollection<OMenuPermissionInfo>(ORoleDAL.GetPermissionByRoleId(RoleId));

        }
    }
}
